<template>
    <CommonContainer title="订单信息">
        <el-descriptions v-if="customerInfo">
            <el-descriptions-item label="合同编号" v-if="customerInfo.orderInfoVo" ><span class="goorder" @click="goOrder(customerInfo.orderInfoVo.orderNo)">{{ customerInfo.orderInfoVo.contractNo|filterNull }}</span></el-descriptions-item>
            <el-descriptions-item label="订单编号"  v-if="customerInfo.orderInfoVo" ><span class="goorder" @click="goOrder(customerInfo.orderInfoVo.orderNo)">{{ customerInfo.orderInfoVo.orderNo|filterNull }}</span></el-descriptions-item>
            <el-descriptions-item label="年行驶公里数" v-if="customerInfo.orderInfoVo">
                {{ customerInfo.orderInfoVo.maintenanceAnnualMileageVal|filterNull }}
            </el-descriptions-item>
            <el-descriptions-item label="月维保费" v-if="customerInfo.orderInfoVo">
                {{ customerInfo.orderInfoVo.maintenanceMonthlyPrice|filterNull }}
            </el-descriptions-item>
            <el-descriptions-item label="付款频次" v-if="customerInfo.orderInfoVo">
                {{ customerInfo.orderInfoVo.payFrequency|filterNull }}
            </el-descriptions-item>
            <el-descriptions-item label="支付时间" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.paymentDate==0?'先付':'后付'|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="是否包含替车" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.isReplacementCar==0?'否':'是'|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="是否含司机" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.isBringDriver==0?'否':'是'|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="合同保证金" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.margin|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="首期租金" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.firstPayMoney|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="残值金额" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.endPayMoney|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="其他加装费" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.retrofittingFee|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="GPS费用" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.gpsAmount|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="购置税" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.purchaseTaxPrice|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="上牌费" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.registerPrice|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="物流费" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.logisticFee|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="每期租金" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.planRent|filterNull }}</el-descriptions-item>
            <el-descriptions-item label="租期" v-if="customerInfo.orderInfoVo">{{ customerInfo.orderInfoVo.leaseTerm|filterNull }}</el-descriptions-item>
            
        </el-descriptions>
    </CommonContainer>
</template>

<script>
import { OrderParam,} from '@/api/finance/manage/collect/api.js';
import {
  getQuotaProductByOrderCar
} from "@/api/carInventory/inInventory";
export default {
    components: {},
    dicts:['business_type','customer_level','customer_label'],
    props: {
        value: {
        type: Object,
        },
    },
    data() {
        return {
          quotaProduct:{}
        }
    },
    mounted() {
      this.detailInfo()
    },
    computed:{
        customerInfo: {
            get() {
                return this.value;
                return this.useVModel.call(this);
            },
            set(val) {
                this.$emit("input", val);
            },
        },
    },
    methods: {
      detailInfo(){
        var _this = this;
        if (this.customerInfo != null && this.customerInfo.carInStorage != null) {
          this.getQuota(this.customerInfo.orderInfoVo.orderNo, this.customerInfo.carBasicVo.modelName);
        } else {
          setTimeout(function () {
            _this.detailInfo();
          }, 100)
        }
      },
        goOrder(orderCode){
            if (this.Empty(orderCode)) return;
            return new Promise(resolve => {
                OrderParam(orderCode)
                .then(res => {
                    if (res.code == 200) {
                        this.$router.push({
                            name: 'OrderDetails',
                            query: {
                            type: res.data.carType,
                            beFrom: 'OrderView',
                            orderId: res.data.orderId,
                            preOrderId: res.data.preOrderId,
                            calcSchemeId: res.data.calcSchemeId,
                            isMenu: this.$route.query.isMenu,
                            },
                        })
                    } else {
                    throw new Error(res);
                    }
                })
            .catch(err => resolve());
        });
        },
      getQuota(orderCode, carModelName){
        if (this.Empty(orderCode)) return;
        if (this.Empty(carModelName)) return;
        getQuotaProductByOrderCar(orderCode, carModelName).then(res => {
          var pd = res.data;
          if (!pd) {
            pd = {};
          }
          if (!pd['plan']) {
            pd['plan'] = {};
          }
          this.quotaProduct = pd;
          this.customerInfo.orderInfoVo.gpsAmount = pd.plan.gpsFee;
          this.customerInfo.orderInfoVo.maintenanceMonthlyPrice = pd.maintenancePrice;
          this.customerInfo.orderInfoVo.purchaseTaxPrice = pd.carPurchaseTax;
          this.customerInfo.orderInfoVo.endPayMoney = pd.plan.planResidual;
          this.customerInfo.orderInfoVo.maintenanceAnnualMileageVal = pd.maintenanceAnnualMileageKey;
          this.customerInfo.orderInfoVo.payFrequency = pd.plan.planPaymentFrequencyTypeStr;
          this.customerInfo.orderInfoVo.paymentDate = pd.plan.planPaymentMethodType;
          this.customerInfo.orderInfoVo.margin = pd.plan.planContractCashdeposit;
          this.customerInfo.orderInfoVo.firstPayMoney = pd.plan.planFirstRent;
          this.customerInfo.orderInfoVo.retrofittingFee = Number(pd.otherFeeAmount) + Number(pd.attachedDecorationAmount);
          this.customerInfo.orderInfoVo.registerPrice = pd.carLicensePrice;
          this.customerInfo.orderInfoVo.logisticFee = pd.plan.logisticFee;
          this.customerInfo.orderInfoVo.planRent = pd.plan.planRent;
          this.customerInfo.orderInfoVo.leaseTerm = pd.plan.planTenancyType;
        }).finally(() => {
          this.loading = false
        })
      },
    },
}
</script>

<style lang="scss" scoped>
.goorder{
    color:blue;
    cursor: pointer;
}
</style>
